--- interact_link: content/code-examples/demo-free.ipynb kernel_name: python3 kernel_path: content/code-examples has_widgets: false title: |- No objective function example pagenum: 5 prev_page: url: /code-examples/demo-diffusion-encoding.html next_page: url: /code-examples/demo-diffusion.html suffix: .ipynb search: waveform m phase encode flow generate same encoding objective function example simple required mm resolution run te finder comped last compensated bipolar basically opposite previous comment: "***PROGRAMMATICALLY GENERATED, DO NOT EDIT. SEE ORIGINAL FILES IN /content***" ---
No objective function example
import os

os.chdir("../python/")

import build_gropt
build_gropt.build_gropt()
import gropt

from helper_utils import *
from interactive_plots import plot_waveform_interactive
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
from IPython.core.display import display, HTML
init_notebook_mode(connected = True)
config={'showLink': False, 'displayModeBar': False}
from timeit import default_timer as timer

%matplotlib inline
Building GrOpt . . .

Simple Phase Encode

Generate a waveform with $M_0 = 11.74$, which is the phase encode required to encode 1mm resolution.

params = {}
params['mode'] = 'free'
params['gmax']  = 50
params['smax']  = 50.0
params['moment_params']  = [[0, 0, 0, -1, -1, 11.74, 1.0e-3]]
params['TE']  = 1.0
params['dt']  = 20e-6

G, dd = gropt.gropt(params)

fig = plot_waveform_interactive(G, params, width=585, height=430)
plot(fig, filename = 'fig.html', config = config)
display(HTML('fig.html'))

Run TE finder for same waveform

G_min, T_min = get_min_TE(params)

fig = plot_waveform_interactive(G_min, params, width=585, height=430)
plot(fig, filename = 'fig.html', config = config)
display(HTML('fig.html'))

Flow comped phase encode

Generate a waveform with $M_0 = 11.74$ and $M_1 = 0$.

So the same phase encoding as the last waveform, but flow compensated.

params = {}
params['mode'] = 'free'
params['gmax']  = 0.05
params['smax']  = 50.0
params['moment_params']  = [[0, 0, 0, -1, -1, 11.74, 1.0e-3]]
params['moment_params'].append([0, 1, 0, -1, -1, 0, 1.0e-3])
params['TE']  = 2.04
params['dt']  = 20e-6

G, dd = gropt.gropt(params)

fig = plot_waveform_interactive(G, params, width=585, height=430)
plot(fig, filename = 'fig.html', config = config)
display(HTML('fig.html'))

Flow encoding bipolar

Basically the opposite of the previous waveform. $M_0 = 0$ and $M_1 = 11.74$.

params = {}
params['mode'] = 'free'
params['gmax']  = 0.05
params['smax']  = 50.0
params['moment_params']  = [[0, 0, 0, -1, -1, 0.0, 1.0e-3]]
params['moment_params'].append([0, 1, 0, -1, -1, 11.74, 1.0e-3])
params['TE']  = 2.0
params['dt']  = 20e-6

G, dd = gropt.gropt(params)

fig = plot_waveform_interactive(G, params, width=585, height=430)
plot(fig, filename = 'fig.html', config = config)
display(HTML('fig.html'))